local class = reload("class")
local super = reload("object.super")

---@class npc:objsuper
local this = class(super)

function this:ctor(info)
    super.ctor(self, info)
    self:clear()
end

function this:clear()
end

---对话检查
function this:check(obj)
    --验证距离
    local nx = self:x()
    local ny = self:y()
    local nz = self:z()
    local ox = obj:x()
    local oy = obj:y()
    local oz = obj:z()
    local dist = math.sqrt(
        (nx - ox) * (nx - ox) +
        (ny - oy) * (ny - oy) +
        (nz - oz) * (nz - oz)
    )
    local cdis = self._info.cdis or 3
    if dist > cdis then
        return false
    end
    return true
end

---点击npc
function this:click(obj)
    if not check(obj) then
        return
    end

    ---关联npc
    obj:click(self)
end

function this:talkStart(obj)
    if not check(obj) then
        return
    end
end

function this:taskStart(obj, tid)
    if not check(obj) then
        return
    end
end

---对话npc
function this:dialog(obj)
    if not check(obj) then
        return
    end
end

return this

--[[
    1.普通对话-不可共存
    2.任务对话-可以共存
    3.传送对话-不可共存
    4.商店对话-不可共存
    5.功能对话-不可共存
]]
